package com.cac.demo.newCode.materialStorage.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cac.demo.newCode.materialStorage.mapper.InventoryDetailsMapper;
import com.cac.demo.newCode.materialStorage.dto.InventoryDetailDTO;
import com.cac.demo.newCode.materialStorage.service.InventoryDetailsService;
import com.cac.demo.newCode.materialStorage.vo.InventoryDetailVO;
import com.cac.demo.util.adapter.ResponseMsg;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class InventoryDetailsServiceImpl implements InventoryDetailsService {

    @Resource
    InventoryDetailsMapper inventoryDetailsMapper;

    @Override
    public ResponseMsg<Object> PageInventoryDetails(InventoryDetailDTO inventoryDetailDTO) {
        ResponseMsg<Object> responseMsg = new ResponseMsg<>();
        //拼接分页参数
        Page<?> page = new Page<>(inventoryDetailDTO.getCurrentPage(),inventoryDetailDTO.getPageSize());
        page.setOptimizeCountSql(false);
        IPage<InventoryDetailVO> inventoryDetailVO = inventoryDetailsMapper.PageInventoryDetails(page,inventoryDetailDTO);
        responseMsg.setResponseBody(inventoryDetailVO);
        return responseMsg;
    }
}
